﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web/Master/BackMasterPage.master" AutoEventWireup="true" CodeFile="BookManage.aspx.cs" Inherits="Web_Back_BookList" %>

<%-- 在此处添加内容控件 --%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form id="formBookList" runat="server">

        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">图书详细信息</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
          <div class="btn-group me-2">
               <asp:TextBox Style="display: none;" ID="BookState" runat="server"></asp:TextBox>
               <asp:TextBox Style="display: none;" ID="NewState" runat="server"></asp:TextBox>
            <asp:Button class="btn btn-sm btn-outline-secondary"  ID="BtnGetUp" runat="server" Text="已上架" OnClick="BtnGetUp_Click"/>
            <asp:Button class="btn btn-sm btn-outline-secondary"  ID="BtnGetWaitUp" runat="server" Text="待上架" OnClick="BtnGetWaitUp_Click"/>
              <asp:Button class="btn btn-sm btn-outline-secondary"  ID="BtnDown" runat="server" Text="已下架" OnClick="BtnDown_Click"/>
          </div>
          <%--<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
            <span data-feather="calendar"></span>
            This week</button>--%>
        </div>
      </div>


        <div id="page-wrapper">
            <!-- /.row -->
            <div class="panel panel-default">
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>封面</th>
                                <th>书名</th>
                                <th>作者</th>
                                <th>译者</th>
                                <th>出版社</th>
                                <th>推荐语</th>
                                <th>描述</th>
                                <th>价格</th>
                                <th>类别</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="odd gradeX">
                                <td disable="true">-</td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="图片路径" ID="TextBookImage" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="书名" ID="TextBookName" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="作者" ID="TextBookAuthor" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="译者" ID="TextTranslator" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="出版社" ID="TextPubname" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="推荐语" ID="TextOneword" runat="server"></asp:TextBox></td>
                                <td>
                                    <asp:TextBox class="form-control" placeholder="描述" ID="TextBookDescription" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:TextBox class="form-control" placeholder="价格" ID="TextBookPrice" runat="server"></asp:TextBox></td>
                                <td style="width: 8%;">
                                    <asp:DropDownList class="form-control" ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="typeName" DataValueField="id"></asp:DropDownList>

                                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conStr1 %>" SelectCommand="SELECT * FROM [booktype]"></asp:SqlDataSource>

                                </td>
                                <td style="width: 8%;">
                                    <asp:DropDownList class="form-control" ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2" DataTextField="stateName" DataValueField="id"></asp:DropDownList>

                                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:conStr1 %>" SelectCommand="SELECT * FROM [bookstate]"></asp:SqlDataSource>

                                </td>
                                <td>
                                    <asp:Button class="btn btn-success" ID="BtnAddBook" runat="server" Text="添加" OnClick="BtnAddBook_Click" />
                                </td>
                            </tr>
                            <%=BooksList %>
                        </tbody>
                    </table>
                </div>
                <!-- /.panel-body -->
            </div>
            <!-- /.row -->
        </div>

        <!-- /#wrapper -->
        <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="text-danger">您确定要删除这条记录吗？</h3>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <asp:TextBox Style="display: none;" ID="BookId" runat="server"></asp:TextBox>
                        <asp:Button class="btn btn-danger btn-ok" ID="BtnDeleteBook" runat="server" Text="删除" OnClick="BtnDeleteBook_Click" />
                    </div>
                </div>
            </div>
        </div>

        
        <script>
            $(function () {

                var index = $(<%=BookState.ClientID%>).val() - 1;
                if (index >= 0) {
                    $(".btn-group").find(".btn-outline-secondary").eq(index).addClass("active");
                }

                $(".btn_delete").click(function () {
                    console.log($(this).parent().attr("bookId"));
                    $(<%=BookId.ClientID%>).val($(this).parent().attr("bookId"));
                });
                $(".btn_update").click(function () {
                    window.location.href = "UpdateBookInfo.aspx?bookId=" + $(this).parent().attr("bookId");
                });

            });
    </script>
    </form>
</asp:Content>
